/*
 * MediaPipe 全局配置
 */

// 使用 unpkg CDN，通常有更好的 CORS 支持
export const MEDIAPIPE_ASSETS_BASE_URL = import.meta.env.VITE_MEDIAPIPE_ASSETS_BASE_URL ??
  'https://unpkg.com/@mediapipe/tasks-vision@0.10.21/wasm';

export const MEDIAPIPE_DEFAULTS = {
  wasmLoaderPath: `${MEDIAPIPE_ASSETS_BASE_URL}/vision_wasm_internal.js`,
  wasmBinaryPath: `${MEDIAPIPE_ASSETS_BASE_URL}/vision_wasm_internal.wasm`,
  poseModelPath: import.meta.env.VITE_MEDIAPIPE_POSE_MODEL_URL ??
    'https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite.task',
};

export const DEFAULT_POSE_DETECTION_INTERVAL = 120; // 毫秒
export const DEFAULT_MIN_CONFIDENCE = 0.5;
export const DEFAULT_MIN_TRACKING_CONFIDENCE = 0.5;

export const MAX_PERSON_BOXES = 3; // 最大输出的检测人物数量

export interface PoseDetectionConfig {
  runningMode?: 'VIDEO' | 'IMAGE';
  maxPersons?: number;
  minPoseDetectionConfidence?: number;
  minPosePresenceConfidence?: number;
  minTrackingConfidence?: number;
}

export const DEFAULT_POSE_DETECTION_CONFIG: PoseDetectionConfig = {
  runningMode: 'VIDEO',
  maxPersons: MAX_PERSON_BOXES,
  minPoseDetectionConfidence: DEFAULT_MIN_CONFIDENCE,
  minPosePresenceConfidence: DEFAULT_MIN_CONFIDENCE,
  minTrackingConfidence: DEFAULT_MIN_TRACKING_CONFIDENCE,
};
